<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
       tr{
           height: 40px;
       }

       button{
           width: 30px;
           height: 100px;
           border: none;
       }
    </style>
</head>
<body>
<button style="width: 100px;height: 30px;"><a href="form.html" style="text-decoration: none;color: orange">添加信息</a></button>
<table border="1px" cellspacing="0px" cellpadding="0px" width="1500px" style="height: auto;text-align: center">
    <tr>
        <td>id</td>
        <td>姓名：</td>
        <td>年龄：</td>
        <td>密码：</td>
        <td>确认密码：</td>
        <td>性别：</td>
        <td>手机号：</td>
        <td>家乡：</td>
        <td>兴趣爱好：</td>
        <td width="300px">个人介绍：</td>
        <td>创建时间</td>
        <td>更新时间</td>
       <td>操作：</td>
    </tr>
<!---->
<!--    <tr>-->
<!--        <td></td>-->
<!---->
<!--        <td></td>-->
<!---->
<!--        <td></td>-->
<!---->
<!--        <td></td>-->
<!---->
<!--        <td></td>-->
<!---->
<!--        <td></td>-->
<!---->
<!---->
<!--        <td>-->
<!--            <button style="background-color: #9aff02;width: 100px;height: 30px;">更改</button>-->
<!---->
<!--            <button style="background-color: red; width: 100px;height: 30px;">删除</button>-->
<!--        </td>-->
<!---->
<!--    </tr>-->


    <?php
$server = "localhost";
$user = "root";
$pwd = "root";
$database = "tur";
$ulinix = mysqli_connect($server, $user, $pwd, $database);
        if ($ulinix) {


            $query=" select * from tur";
            $queryok=mysqli_query($ulinix,$query);
            if(mysqli_num_rows($queryok)>0){
                while ($row = mysqli_fetch_assoc($queryok)){
                    echo "<tr style='background-color: #02efc5; color: white;height: 40px;' align='center' class='#a0ff00'>";
                    echo "<td class='br'>".$row['id']."</td>";
                    echo "<td class='br'>".$row['name']."</td>";
                    echo "<td class='br'>".$row['age']."</td>";
                    echo "<td class='br'>".$row['password1']."</td>";
                    echo "<td class='br'>".$row['password2']."</td>";
                    //把sex选项这样写也可以的
//                   $sex=$row['sex'];
//                   switch ($sex){
//                       case 1:
//                           $sex="男";
//                           break;
//                       case 2:
//                           $sex="女";
//                           break;
//                   }
//                    echo "<td class='br'>".$sex."</td>";
                   echo "<td class='br'>".($row['sex']==1?'男':'女')."</td>";

                    echo "<td class='br'>".$row['tel']."</td>";
                    switch ($row['hometown']){
                        case 1:
                            $hometown = "北京";
                            break;
                        case 2:
                            $hometown = "上海";
                            break;
                        case 3:
                            $hometown = "天津";
                            break;
                        case 4:
                            $hometown = "深圳";
                            break;
                        case 5:
                            $hometown = "乌鲁木齐";
                            break;
                        case 6:
                            $hometown = "喀什";
                            break;
                            case 7:
                            $hometown = "和田";
                            break;
                    }
                    echo "<td class='br'> ".$row['hometown']."</td>";

                    $hobby = explode("#",$row['hobby']);
                    $hby = "";
                    foreach ($hobby as $h){
                        switch ($h){
                            case 1:
                                $hby .= "读书, ";
                                break;
                            case 2:
                                $hby .= "编程, ";
                                break;
                            case 3:
                                $hby .= "打工, ";
                                break;
                            case 4:
                                $hby .= "游泳, ";
                                break;
                            case 5:
                                $hby .= "花钱, ";
                                break;
                                case 6:
                                $hby .= "篮球, ";
                                break;
                                case 7:
                                $hby .= "跑车, ";
                                break;
                                case 8:
                                $hby .= "旅游, ";
                                break;
                        }
                    }

                    echo "<td class='br'>".$hby."</td>";
                    echo "<td class='br'>".$row['description']."</td>";
                    echo "<td class='br'>".$row['created_at']."</td>";
                    echo "<td class='br'>".$row['updated_at']."</td>";
                   echo "<td><a href='' style='color: white'>编辑</a> <a href='' style='color: white'>删除</a></td>";
                    echo "</tr>";
                }
            }else{
                echo "数据添加失败：".mysqli_error($ulinix);
            }
            mysqli_close($ulinix);
        }else {
            echo "链接失败！";
            echo mysqli_connect_error();
        }



       $r=$row['hometown'];
    echo "<h1 style='color: red' >$r</h1>";

    ?>
</body>
</html>
